package atguigu.exception;

import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;

public class ExceptionTest {

    public static void main(String[] args) {

        ExceptionTest et = new ExceptionTest();
        try {
            et.funca();
        } catch (Exception e) {
//            System.out.println(e.getMessage());
            e.printStackTrace();
        }


    }


    public void funcd() throws Exception{

        Foo dest = new Foo();
        Foo orig = null;
        if(orig == null){
            throw new Exception("拷贝对象报错0"); // 这种可以catch到
        }

        try {
            BeanUtils.copyProperties(new Foo(),null);
        } catch (IllegalAccessException e) {
            throw new Exception("拷贝对象报错1",e); // 这里的捕获不到
        } catch (InvocationTargetException e) {
            throw new Exception("拷贝对象报错2",e);
        }
    }


    public void funca() throws Exception{

        try{
            funcd();

        }catch (Exception e){
            throw new Exception(String.format("拷贝对象失败 %s","funca"),e);
        }

        funcb();

        throw new Exception("funca");

    }


    public void funcb() throws Exception{

        funcc();

        throw new Exception("funcb");
    }

    public void funcc() throws Exception{
        throw new Exception("funcc");
    }
}
